
{{from gluon.contrib.markdown import WIKI}}
<script>
function toggle(id) {
  $(".postrow").hide();
  $("#post"+id).show();
}
function closerow(id) {
  $("#post"+id).hide();
}
$("#like").click(function(){
	$(this).hide();
});
</script>
<style type="text/css">
#comments_side_out
{
	color:#B4045F;
	font-family:"Times New Roman";
	font-size: 1.3em;
        text-align: left;
 /*       border:1px solid #175966;*/
}
#comments_side_out tr td a
{
    	font-size: 1.6 em;
 /*      border:1px solid #175966;*/
}
#first_line
{
        font-style:italic;
    	font-size: 3 em;
        color:#424242;
 /*      border:1px solid #175966;*/
}
</style>

<!-- define a function for displaying comment tree-->
{{def listcomments(id):}}
{{if not tree.has_key(id): return}}
<table id="comments_side_out">
{{for item in tree[id]:}}
<tr><td>

   <table>
   <tr><td id="first_line"><font size= 2>{{=A(item.author_alias,_href=URL(r=request,f='person',args=[item.author]))}} {{=timesince(item.post_time,now)}} ago said:</font></td></tr>
   <tr><td><font size=3><p>{{=WIKI(item.body.strip())}}</p></font></td></tr>
   <tr><td>
            {{if session.authorized:}}
		<!-- 'like' function -->
		<form>
			<INPUT type="hidden" id='q' value="{{=item.id}}"/>
		</form>
                <font size=1><div id="target{{=item.id}}"></div></font>
                <font size=2>
		<a id="like" type="text" 
		onclick="$('#q').attr('value','{{=item.id}}');$(this).hide();
		ajax('{{=URL(r=request,f='vote_comment')}}',['q'],'target{{=item.id}}');">like</a>
<!--		{{=A('report',_href=URL(r=request,f='report_comment',args=[item.id]))}} 
		{{=A('reply',_href="javascript:toggle(%i)"%item.id if session.authorized else URL(r=request,f='login'))}} 
		{{if item.author==session.authorized:}}
			{{=A('edit',_href=URL(r=request,f='edit_comment',args=[item.id]))}} 
		{{pass}}-->
                </font>
           {{pass}}
                <font size=2>{{=A('reply',_href="javascript:toggle(%i)"%item.id if session.authorized else URL(r=request,f='login'))}}
                 </font>
	</td></tr>
{{if forms:}}<tr class="postrow" id="post{{=item.id}}"><td>{{=forms[item.id]}}
	<div style="text-align:right">
	<a href="javascript:closerow({{=item.id}})">close</a></div>
	</td></tr>
{{pass}}
	<tr><td>{{listcomments(item.id)}}</td></tr>
   </table>
   <script>$("#post{{=item.id}}").hide()</script>
</td></tr>
{{pass}}
</table>
{{return}}
<!--END define a function for displaying comment tree-->

{{if item:}}
<table><tr><td>
   <table border="0" cellpadding="0" cellspacing="0">
  </table>
</td><td>
  <table>
  <tr><td class="article">
  </td></tr>
  <tr><td>
  </td></tr>
  </table>
</td></tr></table>
{{pass}}
{{if form:}}
<p><b>Comments</b></p>
<p class="postrow">
{{=form}}
</p>
{{pass}}

{{listcomments(parent)}}